import type React from "react"
import { use } from "react"
import {
  Breadcrumb,
  BreadcrumbItem,
  BreadcrumbLink,
  BreadcrumbList,
  BreadcrumbPage,
  BreadcrumbSeparator,
} from "@/components/ui/breadcrumb"
import Link from "next/link"
import { Home } from "lucide-react"

export default function AlgorithmLayout({
  children,
  params,
}: {
  children: React.ReactNode
  params: Promise<{ id: string }>
}) {
  const resolvedParams = use(params)
  // 算法名称映射
  const algorithmNames: Record<string, string> = {
    "dynamic-graph-generation": "动态异构图展示",
    "dynamic-graph-analysis": "动态异构图分析方法",
    "data-flow-risk": "数据流动风险防范优化算法",
    "dynamic-graph-facetnet": "FacetNet动态异构图生成算法",
    "anomalous-edge-detection": "异常边检测算法",
  }

  const algorithmName = algorithmNames[resolvedParams.id] || resolvedParams.id

  return (
    <div className="container mx-auto py-6 px-4">
      <Breadcrumb className="mb-6">
        <BreadcrumbList>
          <BreadcrumbItem>
            <BreadcrumbLink asChild>
              <Link href="/">
                <Home className="h-4 w-4" />
              </Link>
            </BreadcrumbLink>
          </BreadcrumbItem>
          <BreadcrumbSeparator />
          <BreadcrumbItem>
            <BreadcrumbPage>{algorithmName}</BreadcrumbPage>
          </BreadcrumbItem>
        </BreadcrumbList>
      </Breadcrumb>
      {children}
    </div>
  )
}

